<%-- 
    Document   : register-box
    Created on : 23-04-2011, 23:51:55
    Author     : DoanHa
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
 <script type="text/javascript">
    function validateRegisterForm()
    {
        var fullName = document.forms["registerForm"]["fullName"].value
        if(fullName == null || fullName == "")
        {
            alert("Vui lòng nhập họ tên");
            return false;
        }

        var password = document.forms["registerForm"]["password"].value
        if(password == null || password == "")
        {
            alert("Vui lòng nhập mật khẩu");
            return false;
        }

        var retypePassword = document.forms["registerForm"]["retypePassword"].value
        if(retypePassword == null || retypePassword == "")
        {
            alert("Vui lòng nhập mật khẩu xác nhận");
            return false;
        }

        var captcha = document.forms["registerForm"]["captcha"].value
        if(captcha == null || captcha == "")
        {
            alert("Vui lòng nhập mã bảo vệ");
            return false;
        }

        var emailReg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
        var email = document.forms["registerForm"]["email"].value
        if(emailReg.test(email) == false) {
            alert('Email không đúng định dạng! VD: doanlang.mh@gmail.com');
            return false;
        }
    }
</script>
 
<div id="content">
    <div id="register-box">
        <div class="contentTitle">
            <span class="title"><center><b><bean:message key="register.label.title" /></b></center>
            </span>
        </div>
        <div>
            <div>
                <html:form action="/submitRegister" onsubmit="return validateRegisterForm();">
                    <table>
                        <tr>
                            <td style="color: red" colspan="2">
                                <html:errors />
                            </td>
                        </tr>
                        <tr>
                            <th><bean:message key="register.label.fullname" /></th>
                            <td><html:text property="fullName" /></td>
                        </tr>
                        <tr>
                            <th><bean:message key="register.label.email" /></th>
                            <td>
                                <html:text property="email"/>
                                
                            </td>
                        </tr>
                         <tr>
                            <th><bean:message key="register.label.password" /></th>
                            <td><html:password property="password"/></td>
                        </tr>
                         <tr>
                            <th><bean:message key="register.label.retypepassword" /></th>
                            <td><html:password property="retypePassword"/></td>
                        </tr>
                         <tr>
                             <th><bean:message key="register.label.capcha.image" /></th>
                             <td>
                                <img id="captchaImg" src="./CapchaServlet" alt="Captcha Image" height="35">
                                <img src="images/reload.jpg" alt="Reload" onclick="document.forms[0].captchaImg.src='./CapchaServlet?id='+Math.random();" style="cursor:pointer" height="35"/>
                             </td>
                        </tr>
                         <tr>
                            <th><bean:message key="register.label.capcha" /></th>
                            <td>
                                <html:text property="captcha"/>                             
                            </td>
                        </tr>
                        <tr>
                            <td></td>
                            <td>
                                <html:submit><bean:message key="register.button.dangky" /></html:submit>
                                
                            </td>
                        </tr>
                         <tr>
                            <th></th>
                            <td><a href="">Quy định/Chính sách</a></td>
                        </tr>
                    </table>
                </html:form> 
            </div>
        </div>
    </div>
</div>
